package com.agricultural.observer;

import com.agricultural.environment.EnvironmentMonitor;

public class AlertSystem implements EnvironmentObserver {
    @Override
    public void update(EnvironmentMonitor monitor, String message) {
        // 检查环境参数是否超出阈值
        if (monitor.getTemperature() > 30) {
            System.out.println("⚠️ 温度警报: " + monitor.getTemperature() + "°C (过高)");
        }
        
        if (monitor.getHumidity() < 40) {
            System.out.println("⚠️ 湿度警报: " + monitor.getHumidity() + "% (过低)");
        }
        
        if (monitor.getSoilPH() < 5.5 || monitor.getSoilPH() > 7.5) {
            System.out.println("⚠️ 土壤pH值警报: " + monitor.getSoilPH() + " (异常)");
        }
    }
}    